package test.example

import android.bluetooth.BluetoothManager
import android.content.Context

import org.junit.Assert.assertNotNull
import org.junit.Assert.assertNull
import org.junit.Test

import test.BaseRobolectricTest
import test.shadow.MyShadowBluetoothAdapter

class ExampleRobolectricTest : BaseRobolectricTest() {
    override fun setUp() {
        super.setUp()
    }

    override fun tearDown() {
        super.tearDown()
    }

    @Test
    fun getBleScannerSuccess() {
        val manager = context.getSystemService(Context.BLUETOOTH_SERVICE) as BluetoothManager
        val adapter = manager.adapter
        val scanner = adapter.bluetoothLeScanner

        assertNotNull(scanner)
    }

    @Test
    fun getBleScannerFail() {
        MyShadowBluetoothAdapter.setScannerEnabled(false)

        val manager = context.getSystemService(Context.BLUETOOTH_SERVICE) as BluetoothManager
        val adapter = manager.adapter
        val scanner = adapter.bluetoothLeScanner

        assertNull(scanner)
    }
}